home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / DATES.TXT < prev    next >
Text File  |  1996-07-04  |  4KB  |  83 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   DATES   .TXT ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. For most business and personal applications nothing that happened before
  19. Jan. 1, 1872 and nothing that is going to happen after Dec. 31, 2050 has
  20. any importance, so, this extremely fast and efficient method of packing
  21. dates into 2byte WORDs is just what the doctor ordered!
  22.  
  23. Storing dates has always been a memory hungry process!  In years past we
  24. could store just the last 2 numbers and assume the 19.  But, as the 21st
  25. century looms large upon the horizon we no longer have that luxury. This
  26. system solves both the problem of byte hungry storage and spanning the 2
  27. centuries.
  28.  
  29. Also, when the  date has been reduced to a number  it is quite simple to
  30. compute things like:  ages, elapsed time, future payment dates, etc. You
  31. can also simply convert from one display style to another, or even run a
  32. quick check on the validity of an input date string.
  33.  
  34. With the advent of international BBSing  the speed of software dispersal
  35. has become a matter of everyday life. A program you put up in California
  36. today will be in Europe the next! Because there are three different ways
  37. to display a date (not counting for separating characters) your programs
  38. should be able to "switch gears" at a moments notice. This system allows
  39. this to happen with almost NO extra coding on your part and is very easy
  40. to maintain as you will always be working with WORDs and numbers and not
  41. a 10byte string.
  42.  
  43.                  01\31\1994   American Style DD\MM\YYYY
  44.                  31.01.1994   European Style MM.DD.YYYY
  45.                  1994-01-31   Japanese Style YYYY-MM-DD
  46.  
  47. The user's preference for date styles can be found in his/her system so
  48. it is a very simple matter to provide what is wanted for each and every
  49. user, or offer them a choice, even if they change there minds every day!
  50.  
  51. Some things to remember about dates when you are doing your math:
  52.  
  53.   1) Leap year is a year that is:
  54.        DIVISIBLE BY 4         but
  55.        NOT DIVISIBLE BY 100   unless
  56.        DIVISIBLE BY 400
  57.      ie: 1800 wasn't a leap year BUT 2000 is a leap year!
  58.  
  59.   2) Work in units of 4 years: 1461 days
  60.  
  61.   3) Jan. 1, 1872 was a Monday
  62.      ie:  DayOfTheWeek? = ( PackedDate?? MOD 7 )
  63.  
  64.   4) when converting from one display style to another first convert
  65.      the string to a number, then change the style setting, and finally
  66.      do the conversion. Don't attempt a string to string conversion as
  67.      it is too costly in time and code.
  68.  
  69. DOS stores dates in a WORD also but it is quite a different style than
  70. the one described above. This system works on dates after Dec.31, 1980
  71. and is not capable of math functions, etc.  In other words,  it is NOT
  72. as handy as our system but has been included here because the routines
  73. to implement this system were, for the large part, required to convert
  74. the system's date for our system.
  75.  
  76. In the event some unsupported display type is required by your program
  77. there are sufficient routines included in this library to allow you to
  78. quickly create your own functions.
  79.  
  80. NOTE: this whole system is geared to the 10 character date string. It
  81.       is capable of returning an 8 character string but will convert
  82.       it back into Y??, M?, D? using the system's century.
  83.